<?php
namespace app\admin\controller;

use think\Controller;
use think\Db;

class Types extends Controller
{
    public function index(){
        $type = Db::name('types')->select();
        $this->assign("type",$type);
        return $this->fetch();
    }

    public function edit(){
        $tid = input('tid');
        $rs = Db::name('types')->where('tId',$tid)->find();
        $this->assign("rs",$rs);
        return $this->fetch();
    }

    public function update(){
        $tid = input('tid');
        $tname = input('tname');
        $data = [
            'tName' => $tname
        ];
        $rs=Db::name('types')->where('tId',$tid)->update($data);
        $this->redirect('index');
    }

    public function del(){
        $tid = input('tid');
        Db::name('types')->where('tId',$tid)->delete();
        $this->redirect('index');
    }

}
